package com.zz.hhbl.entity

import android.os.Parcelable
import com.amap.api.maps.model.LatLng
import com.amap.api.maps.model.LatLngBounds
import com.zz.framework.core.ext.fromJson
import kotlinx.android.parcel.Parcelize
@Parcelize
data class SpotInfoEntity(
    val address: String? = "",
    val alertDistance: Int? = 0,
    val lockDistance: Int? = 0,
    val id: Int = 0,
    val lockTime: Int? = 0,
    val name: String? = "",
    val platformContactName: String? = "",
    val platformContactPhone: String? = "",
    val searchType: Int? = 0,
    val wakeWord: String? = "",
    val southwestCoordinate: String? = null,
    val northeastCoordinate: String? = null,
    val centerCoordinate: String? = null,
//    val southwestCoordinate: String? = "[103.960088,30.302849]",
//    val northeastCoordinate: String? = "[104.176806,30.510292]",
//    val centerCoordinate: String? = "[104.176806,30.510292]",
    val welcomeData: List<SpotConfigEntity>? = null,
    val bootPageData: List<SpotConfigEntity>? = null,
):Parcelable{
    fun getLatLngBounds():LatLngBounds?{
        var southwestLatLng:LatLng?=null
        var northeastLatLng:LatLng?=null
        southwestCoordinate?.fromJson<List<Double>>()?.let {
            southwestLatLng = LatLng(it[1],it[0])
        }
        northeastCoordinate?.fromJson<List<Double>>()?.let {
            northeastLatLng = LatLng(it[1],it[0])
        }
        return if (southwestLatLng!=null && northeastLatLng!=null){
            LatLngBounds.builder().include(southwestLatLng).include(northeastLatLng).build()
        }else{
            null
        }
    }
}

@Parcelize
data class SpotConfigEntity(
    val name:String?="",
    val url:String?="",
    val type:String?="", //image
    val order:String?="",
):Parcelable